home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / MATHS / RLAB / RLAB125.ZIP / !RLaB / examples / contour < prev    next >
Text File  |  1995-05-20  |  948b  |  58 lines

  1. #
  2. # Simple contour plotting demonstration
  3. #
  4.  
  5. NX = 20;
  6. NY = 20;
  7. xx = zeros (1, NX);
  8. yy = zeros (1, NY);
  9. for (i in 1:NX) { xx[i] = (i - NX/2)/(NX/2); }
  10. for (i in 1:NY) { yy[i] = (i - NY/2)/(NY/2); }
  11.  
  12. zz = zeros (NX, NY);
  13.  
  14. for (i in 1:NX)
  15. {
  16.   for (j in 1:NY)
  17.   {
  18.     r = sqrt (xx[i]^2 + yy[j]^2);
  19.     zz[i;j] = exp (-r * r) * cos (2*pi*r);
  20.   }
  21. }
  22.  
  23. # Sin - Cos surface
  24.  
  25. x1 = -3:3:.2;
  26. y1 = -3:3:.2;
  27. z1 = zeros (x1.n, y1.n);
  28.  
  29. for (i in 1:x1.n)
  30. {
  31.   for(j in 1:y1.n)
  32.   {
  33.     z1[i;j] = sin(y1[j]) * cos(x1[i]);
  34.   }
  35. }
  36.  
  37. # Now create some plots
  38.  
  39. xlabel("X-Axis");
  40. ylabel("Y-Axis");
  41. pltitle ("Contour Demonstration");
  42.  
  43. plmesh (<< x = xx; y = yy; z = zz>>);
  44. pause();
  45.  
  46. plaspect(0.5);
  47. pltitle ("Contour Demonstration, Aspect = 0.5");
  48. plcont (<< x = xx; y = yy; z = zz>>);
  49. plaspect ();
  50. pause();
  51.  
  52. pltitle ("Contour Demonstration");
  53. plmesh (<< x = x1; y = y1; z = z1>>);
  54. pause();
  55.  
  56. pltitle ("Contour Demonstration, Aspect = 1.0");
  57. plcont (<< x = x1; y = y1; z = z1>>);
  58.